<template>

</template>

<script>
    import { qywxWebLogin } from "@/api/login";
    import { getToken, setToken, removeToken, getLesseeId, setLesseeId, removeLesseeId } from '@/utils/auth'
    export default {
      name: "WwloginRedirect",
      data(){
        return {}
      },
      methods: {
        //通过code获取用户信息
        handelLogin(params,callback){
          qywxWebLogin(params).then(function (res) {
            if(res&&callback){
              callback(res)
            }
          })
        },
        //登录，缓存
        handelLoginCall(token){
          let lesseeId = this.$route.query.state
          setToken(token)
          setLesseeId(lesseeId)
          this.$store.commit('SET_TOKEN', token)
          this.$store.commit('SET_LESSEEID', lesseeId)
          this.$router.push({ path: "index" })
        }
      },
      created(){
        let that = this;
        const query = that.$route.query
        that.handelLogin(query, function (res) {
          that.handelLoginCall(res.token)
        });
      }
    }
</script>

<style rel="stylesheet/scss" lang="scss">

</style>
